﻿using System;
using System.Collections;
using System.Collections.Generic;
using AutoChess;
using TMPro;
using UnityEngine;

namespace AutoChess
{
    /// <summary>
    /// 格子绘制时的类型
    /// </summary>
    public enum GridRenderType
    {
        Normal,  //普通
        Selected,//被选中
    }

    /*public class GridUnitRenderer : BaseRenderer
    {
        /// <summary>关联的格子信息 </summary>
        public ACGrid gridUnit;

        private new BoxCollider collider;

        /// <summary>显示格子名称</summary>
        private TextMeshPro gridInfo;

        private GridRenderType gridRenderType;
        private GridRenderType GridRenderType
        {
            set {
                gridRenderType = value;
                RefreshRenderer();
            }
        }

        private void UpdatePostion()
        {
            if (gridUnit != null)
            {
                transform.position = gridUnit.Position;
            }
        }
       
        //变更渲染实体 父节点 . 商店格子
        public void RefreshRoot(Transform newRoot,bool upDown)
        {
            transform.SetParent(newRoot);
            if (upDown)
            {
                transform.localPosition = Vector3.zero;
                transform.localScale = new Vector3(360, 360, 360);//TODO 暂时先写死
                gridUnit.Position = transform.position;
            }
            else
            {
                transform.position = new Vector3(1000,1000,1000);
                gridUnit.Position = new Vector3(1000, 1000, 1000);
            }
        }

        protected override void OnRendererBorn()
        {
        }

        protected override void OnRendererDestroy()
        {
        }

        protected override void OnRendererUpdate()
        {
        }

        public override void OnDisconnect()
        {
            gridUnit = null;
            gridRenderType = GridRenderType.Normal;
            transform.SetUnused(false, GameConst.AC_GRID);
        }

        public  void OnConnect(ACGrid data)
        {
            var temp = data as ACGrid;
            this.gridUnit = temp;
            if (this.gridUnit != null)
            {
                transform.name = this.gridUnit.ToString();
                UpdatePostion();
                gameObject.SetActive(true);

                if (collider == null)
                {
                    collider = gameObject.AddMissingComponent<BoxCollider>();
                }
                if (gridUnit.GridType == GridType.ShopGrid)//商店的碰撞区域大一点
                {
                    collider.size = gridUnit.Size;
                    collider.center = gridUnit.BoxOffset;
                }
                else
                {
                    collider.size = gridUnit.Size;
                }
            }
        }
      
        public override void RefreshRenderer()
        {
         
        }

    }*/
}
